<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\agent\controller;

class MessageConfigController extends \app\AgentRest
{
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        if($this->_user["role_name"] != "admin") {
            echo json_encode(["code" => 401, "error" => lang("Permission denied")]);
            exit;
        }
    }
    public function delMessageByDay()
    {
        if(!isset($this->_input["modular_id"]) || !isset($this->_input["days"])) {
            return $this->success("success");
        }
        $validate = new \think\Validate();
        $validate->rule(["days|清除时间" => "integer"]);
        if(!$validate->check($this->_input)) {
            return $this->error($validate->getError());
        }
        $modular_id = $this->_input["modular_id"];
        $days = $this->_input["days"];
        if(0 < $days) {
            $beginTime = mktime(0, 0, 0, date("m"), date("d") - $days, date("Y"));
        } else {
            $beginTime = 0;
        }
        $rst = \think\facade\Db::name("longbing_card_message")->where([["uniacid", "=", $modular_id], ["create_time", "<", $beginTime]])->delete(true);
        return $this->success($rst);
    }
}

?>